package com.ljy.jymail.order.config;

import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
import org.springframework.data.redis.serializer.GenericJackson2JsonRedisSerializer;
import org.springframework.data.redis.serializer.RedisSerializer;
import org.springframework.session.web.http.CookieSerializer;
import org.springframework.session.web.http.DefaultCookieSerializer;

@Configuration
public class jymailSessionConfig {


    //自定义cookie作用域
    @Bean
    public CookieSerializer cookieSerializer(){
        DefaultCookieSerializer cookieSerializer = new DefaultCookieSerializer();
        //session最大时间
        //cookieSerializer.setCookieMaxAge();
        //session作用域,指定为整个jymail.com
        cookieSerializer.setDomainName("48u4939222.eicp.vip");
        //设置Cookie名字
        cookieSerializer.setCookieName("JYSESSION");
        return cookieSerializer;
    }


    //将序列化机制设置为JSON存入redis
    public RedisSerializer<Object> springSessionDefaultRedisSerializer(){
        //redis序列化机制修改
        return new GenericJackson2JsonRedisSerializer();
    }
}
